import api from '@/src/api';
import { message } from 'antd';

export default {
  namespace: 'keyRateDurationsM',
  state: {},
  effects: {
    //关键利率久期概览
    *getKrdSummary({ payload, callback }, { call, put }) {
      const response = yield call(api.keyRateDurations.getKrdSummary, payload);
      if (response && response.data && response.code == 0) {
        callback(response);
      } else {
        message.error((response && response.msg) || '获取关键利率久期概览失败');
      }
    },

    //关键利率久期明细
    *getKrdDetail({ payload, callback }, { call, put }) {
      const response = yield call(api.keyRateDurations.getKrdDetail, payload);
      if (response && response.data && response.code == 0) {
        callback(response);
      } else {
        message.error((response && response.msg) || '获取关键利率久期明细失败');
      }
    },
  },
  reducers: {
    save(state, { payload }) {
      return { ...state, ...payload };
    },
  },
};
